<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div>
       <canvas id="cvs" width="400" height="400" style="border:1px solid black"></canvas>
    </div>
    <script>
       var canvas = document.getElementById('cvs');
       var ctx = canvas.getContext("2d");
      
      // ctx.rect(x,y,w,h) 画一条矩形的路径 只绘制路径，不描边
     ctx.rect(100,100,200,200)
     ctx.stroke()

     //ctx.stokeRect() 绘制描边矩形
     ctx.strokeStyle="red"
     ctx.strokeRect(150,150,100,100)
    
    //绘制填充矩形
     ctx.fillRect(10,10,60,60)

     //清除画布
     ctx.clearRect(30,30,20,30)
    </script>
</body>
</html>